<script type="text/javascript"><!--//--><![CDATA[//><!--

    var grid_reload = function() {
        $('#datagrid').datagrid('reload', $('#fm_search').serializeObject());
    };
    
    var grid_reload_filter = function(){
        var bulan_dari = $('#bulan_dari').val();
        var bulan_sampai = $('#bulan_sampai').val();
        var tahun = $('#tahun').val();
        var status_bayar = $('#status_bayar').val();
        if( status_bayar=='all'){
            grid_reload();
        } else {
          $('#datagrid').datagrid('reload', {'set':'filter','bulan_dari':bulan_dari,'bulan_sampai':bulan_sampai,'status_bayar':status_bayar,'tahun':tahun});           
        }
    };


    $(document).ready(function() {
       // Setup Datagrid
		$('#datagrid').datagrid({  
			url:gs_path+'/'+controller+'/getdata', 
			queryParams: $('#fm_search').serializeObject(),
			height:340,
			pagination:true,
			//singleSelect:true,
			columns:[[
				{ field : 'ck', checkbox:true, width: 40, align: 'center', rowspan:2},	
				{ field : 'no_tagihan_listrik', title : 'No Tagihan Listrik', width:100, sortable:true, rowspan:2},
				{ field : 'no_bukti_pembayaran', title : 'No Pembayaran', width:130, sortable:true, rowspan:2},
                { field : 'nama_tenant', title : 'Nama Tenant', width:130, sortable:true, rowspan:2},
				{ field : 'no_toko', title : 'No toko', width:100, sortable:true, rowspan:2},
				{ field : 'jenis_usaha', title : 'Jenis Usaha', width:250, sortable:true, rowspan:2},
				{ field : 'periode_pembayaran', title : 'Periode Pembayaran', width:150, sortable:true, rowspan:2},
				{ field : 'kwh_awal_meter', title : 'Kwh Awal Meter', width:100, sortable:true, rowspan:2},
				{ field : 'kwh_akhir_meter', title : 'Kwh Akhir Meter', width:100, sortable:true, rowspan:2},
				{ field : 'kwh_terpakai', title : 'Kwh Terpakai', width:100, sortable:true, rowspan:2},
				{ field : 'tarif_per_kwh', title : 'Tarif Per Kwh', width:100, sortable:true, rowspan:2},	
				{ field : 'jumlah_pemakaian', title : 'Jumlah Pemakaian', width:100, sortable:true, rowspan:2},
				{ field : 'mcb', title : 'MCB yang Terpakai', width:100, sortable:true, rowspan:2},
				{ field : 'biaya_beban', title : 'Biaya Beban', width:100, sortable:true, rowspan:2},
				{ field : 'jumlah_biaya_beban', title : 'Jumlah Biaya Beban', width:100, sortable:true, rowspan:2},
				{ field : 'total_tagihan', title : 'Total Tagihan', width:100, sortable:true, rowspan:2},
				{ field : 'status_bayar', title : 'Status Bayar', width:100, sortable:true, rowspan:2},
			]]
		});


		// Setup Form
		$('#form_master').setupForm([
			{ name: 'bulan_dari', type: 'text', size: 'short'},
			{ name: 'bulan_sampai', type: 'text', size: 'short'},
			{ name: 'tahun', type: 'text', size: 'short'},
			{ name: 'status_bayar', type: 'text', size: 'medium'},
			{ name: 'status_bayar_b', type: 'text', size: 'medium'},
		]);
		
        // Set Action Button
        var buttons = [ 
                        // ----- >> Edit Button
					     { label: 'Print Semua', icon: 'print', onclick: function() {
								var status_bayar = $('#status_bayar').val();
								window.location = gs_path + '/pro_print_excel_new/tagihan_listrik_all/?status_bayar='+status_bayar;
					     }},
					    { label: 'Print Satuan', icon: 'print', onclick: function() {

					    	var oSel = $('#datagrid').datagrid('getSelected');
					        if (oSel == null) {
					            $.messager.alert('&nbsp;', gs_msg_row_unselected, 'warning'); 
					        } else {
								window.location = gs_path + '/pro_print_excel_new/tagihan_listrik_satuan/?no_tagihan_listrik='+urlencode(oSel.no_tagihan_listrik);
					        } 

					    	
					    }},{ label: 'Print PDF', icon: 'print', onclick: function() {
                            var oSel = $('#datagrid').datagrid('getSelected');
                            //alert(no_id);
                            if (oSel == null) {
                                $.messager.alert('&nbsp;', gs_msg_row_unselected, 'warning'); 
                            } else {
                                window.open(gs_path+'/'+controller+'/cetak/?no_tagihan_listrik='+urlencode(oSel.no_tagihan_listrik), 'myWin', 'height=500,width=700,status=yes,toolbar=no,menubar=yes,location=no,scrollbars=yes');
                            }
                        }},

						// ----- >> Download Button
						
						// ----- >> SP Button
					    ];
        setAction(buttons);
		
		
		$('#fm_search').focusFirst();
    });
//--><!]]></script>

    
<div id="tb" style="padding:5px;height:auto">
    <div>
        <form id="fm_search" onsubmit="grid_reload(); return false;">
        	<table class="tb_form" style="margin-bottom:0px">
        		<tr>
        			<td class="label" style="width:70px">Periode Tagihan</td>
        			<td ><select id="bulan_dari" name="bulan_dari">
                        <option value="01">Januari</option>
                        <option value="02">Februari</option>
                        <option value="03">Maret</option>
                        <option value="04">April</option>
                        <option value="05">Mei</option>
                        <option value="06">Juni</option>
                        <option value="07">Juli</option>
                        <option value="08">Agustus</option>
                        <option value="09">September</option>
                        <option value="10">Oktober</option>
                        <option value="11">November</option>
                        <option value="12">Desember</option>
                    </select> S/D 
                    <td ><select id="bulan_sampai" name="bulan_sampai">
                        <option value="01">Januari</option>
                        <option value="02">Februari</option>
                        <option value="03">Maret</option>
                        <option value="04">April</option>
                        <option value="05">Mei</option>
                        <option value="06">Juni</option>
                        <option value="07">Juli</option>
                        <option value="08">Agustus</option>
                        <option value="09">September</option>
                        <option value="10">Oktober</option>
                        <option value="11">November</option>
                        <option value="12">Desember</option>
                    </select> Tahun 
        			<?php
        			$now = date('Y');
        			$pastYear = $now - 10; 
        			echo "<select id='tahun' name='tahun' >";
        			for ($a=$pastYear;$a<=$now;$a++)
        			{
        				echo"<option value='".$a."''>".$a."</option>";	
        			}
        			echo"</select>";
        			?>
        			<td style="width:70px">Status Bayar</td>
        			<td colspan="5"><select id="status_bayar" name="status_bayar">
        				<!--<option value="All">All</option>-->
        				<option value="Belum Bayar">Belum Bayar</option>
        				<option value="Sudah Bayar">Sudah Bayar</option>
        				</select>
                	<a href="#" class="easyui-linkbutton" iconCls="icon-search" onclick="grid_reload_filter(); return false;">Filter Bersarkan Peroide Tagihian</a>
        			</td>
        		</td>
        			<!--<a href="#" class="easyui-linkbutton" iconCls="icon-search" onclick="grid_reload_filter(); return false;">Filter</a>-->
        		</td>
        	</tr>
        	<!-- <tr>
                <td style="width:70px">Status Bayar (All)</td>
        			<td colspan="5"><select id="status_bayar_b" name="status_bayar_b">
        				<option value="all">All</option>
        				<option value="Belum Bayar">Belum Bayar</option>
        				<option value="Sudah Bayar">Sudah Bayar</option>
        				</select>
                	<a href="#" class="easyui-linkbutton" iconCls="icon-search" onclick="grid_reload_filter_status(); return false;">Filter Bersarkan Status Bayar</a>
        			</td>
        		</td>
        	</tr> -->
            <tr>
            	<td width="100">Keyword (All Search)</td>
                <td colspan ="3" ><input type="text" id="keyword" name="keyword" class="textfield medium" />
                	<a href="#" class="easyui-linkbutton" iconCls="icon-search" onclick="grid_reload(); return false;">Search</a>
                    <a href="#" class="easyui-linkbutton" iconCls="icon-blank-file" onclick="$('#fm_search').resetForm(); return false;">Reset</a>
                </td>
            </tr>
            </table>
        </form>
    </div>
</div>
<div id="datagrid" toolbar="#tb"></div>
